xen/arm: Check if the FDT passed by the bootloader is valid
authorJulien Grall <julien.grall@arm.com>
Thu, 20 Apr 2017 15:12:27 +0000 (16:12 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Thu, 20 Apr 2017 17:31:24 +0000 (10:31 -0700)
commit4a9d402746fd6fbd1f319eff29fa768f7d7aa62b
treeeab5cfca1afaf9e0c2ad94ff1f9e327bfac898ad
parentf7d93cee1160bf18f77750da2d5900aee9ca15cc
xen/arm: Check if the FDT passed by the bootloader is valid

There is currently no sanity check on the FDT passed by the bootloader.
Whilst they are stricly not necessary, it will avoid us to spend hours
to try to find out why it does not work.

>From the booting documentation for AArch32 [1] and AArch64 [2] must :
    - be placed on 8-byte boundary
    - not exceed 2MB (only on AArch64)

Even if AArch32 does not seem to limit the size, Xen is not currently
able to support more the 2MB FDT. It is better to crash rather with a nice
error message than claiming we are supporting any size of FDT.

The checks are mostly borrowed from the Linux code (see fixmap_remap_fdt
in arch/arm64/mm/mmu.c).

[1] Section 2 in linux/Documentation/arm64/booting.txt
[2] Section 4b in linux/Documentation/arm/Booting

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/mm.c
xen/arch/arm/setup.c
xen/include/asm-arm/setup.h